package cn.iocoder.yudao.module.ems.dal.mysql.warehousing;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ems.dal.dataobject.warehousing.WarehousingDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ems.controller.admin.warehousing.vo.*;

/**
 * 入库记录 Mapper
 *
 * @author dason
 */
@Mapper
public interface WarehousingMapper extends BaseMapperX<WarehousingDO> {

    default PageResult<WarehousingDO> selectPage(WarehousingPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WarehousingDO>()
                .eqIfPresent(WarehousingDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(WarehousingDO::getTime, reqVO.getBeginTime(), reqVO.getEndTime())
                .eqIfPresent(WarehousingDO::getType, reqVO.getType())
                .eqIfPresent(WarehousingDO::getWarehouser, reqVO.getWarehouser())
                .eqIfPresent(WarehousingDO::getReturnee, reqVO.getReturnee())
                .eqIfPresent(WarehousingDO::getStatus, reqVO.getStatus())
                .orderByDesc(WarehousingDO::getId));
    }

    default List<WarehousingDO> selectList(WarehousingExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WarehousingDO>()
                .eqIfPresent(WarehousingDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(WarehousingDO::getTime, reqVO.getBeginTime(), reqVO.getEndTime())
                .eqIfPresent(WarehousingDO::getType, reqVO.getType())
                .eqIfPresent(WarehousingDO::getWarehouser, reqVO.getWarehouser())
                .eqIfPresent(WarehousingDO::getReturnee, reqVO.getReturnee())
                .eqIfPresent(WarehousingDO::getStatus, reqVO.getStatus())
                .orderByDesc(WarehousingDO::getId));
    }

}
